﻿package fj.site
{
	import flash.display.MovieClip
	import flash.events.Event
	import flash.text.TextField;
	import fj.events.FJEvent
	
	public class FJSection extends MovieClip
	{
		private var _model:Model;
		
		public function FJSection():void
		{
			_model = Model.getInstance();
			_model.conteudo = this;
			
			addEventListener( Event.ENTER_FRAME, inLoop );
		}
		public function out():void
		{
			gotoAndPlay( "out:start" );
			removeEventListener( Event.ENTER_FRAME, inLoop );
			addEventListener( Event.ENTER_FRAME, outLoop );
		}
		private function inLoop( e:Event ):void
		{
			if( currentLabel == "in:end" ){
				gotoAndStop("stand");
				removeEventListener( Event.ENTER_FRAME, inLoop );
			}
		}
		private function outLoop( e:Event ):void
		{
			if( currentLabel == "out:end" ){
				stop();
				removeEventListener( Event.ENTER_FRAME, outLoop );
				dispatchEvent( new FJEvent( FJEvent.OUT ) );
			}
		}
	}
}